<template>
  <el-dialog title="编辑员工" :visible="showDialog" @close="close">
    <el-form label-width="120px">
      <el-form-item label="姓名" prop="username">
        <el-input v-model="formData.username" placeholder="请输入姓名" />
      </el-form-item>
      <el-form-item label="邮箱" prop="email">
        <el-input v-model="formData.email" placeholder="请输入邮箱" />
      </el-form-item>
    </el-form>
    <template #footer>
      <el-row type="flex" justify="center">
        <el-button type="primary" size="small" @click="submit">修改</el-button>
        <el-button size="small" @click="close">取消</el-button>
      </el-row>
    </template>
  </el-dialog>
</template>

<script>
import { editEmployeeInfo } from '@/api/employees'
export default {
  props: {
    showDialog: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      formData: {}
    }
  },
  methods: {
    // 修改信息
    async submit() {
      await editEmployeeInfo(this.formData)
      this.$emit('updateEvent')
      this.close()
    },
    close() {
      this.$emit('update:showDialog', false)
    }
  }
}
</script>

<style>

</style>
